﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace WD.Db.Contract
{
    //先添加 Rbac_LoginInfo 表。

    [Serializable]
    public partial class Rbac_LoginInfo
    {
        public Rbac_LoginInfo()
        {
            LastAccessTime = DateTime.Now;
            LoginToken = Guid.NewGuid();
            CreateTime = DateTime.Now;
            IsDeleted = false;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId">整型ID</param>
        /// <param name="loginName">用户名字</param>
        /// <param name="loginId">用户UserId</param>
        public Rbac_LoginInfo(int userId, string loginName, string loginId)
        {
            LastAccessTime = DateTime.Now;
            LoginToken = Guid.NewGuid();
            CreateTime = DateTime.Now;
            IsDeleted = false;


            UserID = userId;
            LoginId = loginId;
            LoginName = loginName;
        }

        /// <summary>
        /// 存放当前用户的所有权限URL
        /// </summary>
        private List<int> _businessPermissionIdList;

        /// <summary>
        /// 存放当前用户的所有权限URL
        /// </summary>
        public List<int> BusinessPermissionIdList
        {
            get { return _businessPermissionIdList; }
            set { _businessPermissionIdList = value; }
        }

        /// <summary>
        /// 存放当前用户的所有权限URL（小写）
        /// </summary>
        public List<string> BusinessPermissionList
        {
            get
            {
                return string.IsNullOrEmpty(BusinessPermissionString)
                    ? new List<string>()
                    : BusinessPermissionString.Split(",".ToCharArray()).Select(p => (p)).ToList();
            }
            set
            {
                BusinessPermissionString = string.Join(",", value.Select(p => p));
            }
        }
    }


}



